const ENV_CUSTOME_KEY = 'jupiter';
export function getToken() {
  return localStorage.getItem(`${ENV_CUSTOME_KEY}-system-token`);
}
export function setToken(token) {
  return localStorage.setItem(`${ENV_CUSTOME_KEY}-system-token`, token);
}
export function clearToken() {
  return localStorage.removeItem(`${ENV_CUSTOME_KEY}-system-token`);
}

export function getUser() {
  const result = localStorage.getItem(`${ENV_CUSTOME_KEY}-system-user-info`) || '{}';
  return JSON.parse(result);
}
export function setUser(user) {
  const u = JSON.stringify(user);
  return localStorage.setItem(`${ENV_CUSTOME_KEY}-system-user-info`, u);
}
export function clearUser() {
  return localStorage.removeItem(`${ENV_CUSTOME_KEY}-system-user-info`);
}

export function getApplicationInfo() {
  const result = localStorage.getItem(`${ENV_CUSTOME_KEY}-system-app-info`) || '{}';
  return JSON.parse(result);
}
export function setApplicationInfo(app) {
  const u = JSON.stringify(app);
  return localStorage.setItem(`${ENV_CUSTOME_KEY}-system-app-info`, u);
}
export function clearApplicationInfo() {
  return localStorage.removeItem(`${ENV_CUSTOME_KEY}-system-app-info`);
}

export function getDevCode() {
  const result = localStorage.getItem(`dev-code`) || '';
  return result;
}

export function logout() {
  clearUser();
  clearToken();
}
